﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data.SqlClient;
using System.Web.Configuration;
using System.Data;

public partial class _1_8 : System.Web.UI.Page
{

    SqlConnection sqlcon;
    string strCon = WebConfigurationManager.ConnectionStrings["SqlConnectionString"].ConnectionString;

    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            //Session["qiyeid"] = 2;
            //Session["ShenBaoNianDu"] = "2013";
            LabelTiShi.Visible = false;

            sqlcon = new SqlConnection(strCon);
            sqlcon.Open();

            SqlCommand sqlcmd = new SqlCommand("select * from a01108_1 where  DATA_MONTH='" + Session["ShenBaoNianDu"] + "' and qiyeid=" + Session["qiyeid"], sqlcon);
            SqlDataReader reader = sqlcmd.ExecuteReader(CommandBehavior.CloseConnection);
            if (reader.Read())
            {
                TextBoxPFKSL.Text = reader["gasoutput_number"].ToString();
                TextBoxQZGYFQPFKSL.Text = reader["GASOUT_NUM"].ToString();
                TextBoxQZRSFQPFKSL.Text = reader["GASCOAL_NUM"].ToString();
                TextBoxFQPFL.Text = reader["gas_cnt"].ToString();
                TextBoxQZGYFQPFL.Text = reader["tec_outcnt"].ToString();
                TextBoxQZRSFQPFL.Text = reader["fire_outcnt"].ToString();

                reader.Close();
            }
            else //未有记录则新增一条
            {
                reader.Close();

                sqlcmd.CommandText = "INSERT INTO a01108_1(qiyeid,DATA_MONTH) VALUES(" + Session["qiyeid"] + ",'" + Session["ShenBaoNianDu"] + "')";
                sqlcon.Open();
                sqlcmd.ExecuteNonQuery();


            }
            sqlcon.Close();


            //**********读取污染物数据***********         
            sqlcon.Close();
            sqlcmd.CommandText = "select * from a01108_2 where  DATA_MONTH='" + Session["ShenBaoNianDu"] + "' and qiyeid=" + Session["qiyeid"];
            sqlcon.Open();
            reader = sqlcmd.ExecuteReader(CommandBehavior.CloseConnection);

            HiddenField[] hb = new HiddenField[] { this.HiddenField1, this.HiddenField2, this.HiddenField3, this.HiddenField4, this.HiddenField5, this.HiddenField6 };
            TextBox[] tbxQCLHJ = new TextBox[] { this.TextBoxQCLHJ1, this.TextBoxQCLHJ2, this.TextBoxQCLHJ3, this.TextBoxQCLHJ4, this.TextBoxQCLHJ5, this.TextBoxQCLHJ6 };
            TextBox[] tbxXZSSQCL = new TextBox[] { this.TextBoxXZSSQCL1, this.TextBoxXZSSQCL2, this.TextBoxXZSSQCL3, this.TextBoxXZSSQCL4, this.TextBoxXZSSQCL5, this.TextBoxXZSSQCL6 };
            TextBox[] tbxRSFQQCL = new TextBox[] { this.TextBoxRSFQQCL1, this.TextBoxRSFQQCL2, this.TextBoxRSFQQCL3, this.TextBoxRSFQQCL4, this.TextBoxRSFQQCL5, this.TextBoxRSFQQCL6 };
            TextBox[] tbxGYFQQCL = new TextBox[] { this.TextBoxGYFQQCL1, this.TextBoxGYFQQCL2, this.TextBoxGYFQQCL3, this.TextBoxGYFQQCL4, this.TextBoxGYFQQCL5, this.TextBoxGYFQQCL6 };
            TextBox[] tbxPFLHJ = new TextBox[] { this.TextBoxPFLHJ1, this.TextBoxPFLHJ2, this.TextBoxPFLHJ3, this.TextBoxPFLHJ4, this.TextBoxPFLHJ5, this.TextBoxPFLHJ6 };
            TextBox[] tbxPFLDBL = new TextBox[] { this.TextBoxPFLDBL1, this.TextBoxPFLDBL2, this.TextBoxPFLDBL3, this.TextBoxPFLDBL4, this.TextBoxPFLDBL5, this.TextBoxPFLDBL6 };
            TextBox[] tbxPFLCBL = new TextBox[] { this.TextBoxPFLCBL1, this.TextBoxPFLCBL2, this.TextBoxPFLCBL3, this.TextBoxPFLCBL4, this.TextBoxPFLCBL5, this.TextBoxPFLCBL6 };
            TextBox[] tbxRSFQHJ = new TextBox[] { this.TextBoxRSFQHJ1, this.TextBoxRSFQHJ2, this.TextBoxRSFQHJ3, this.TextBoxRSFQHJ4, this.TextBoxRSFQHJ5, this.TextBoxRSFQHJ6 };
            TextBox[] tbxRSFQCBL = new TextBox[] { this.TextBoxRSFQCBL1, this.TextBoxRSFQCBL2, this.TextBoxRSFQCBL3, this.TextBoxRSFQCBL4, this.TextBoxRSFQCBL5, this.TextBoxRSFQCBL6 };
            TextBox[] tbxRSFQDBL = new TextBox[] { this.TextBoxRSFQDBL1, this.TextBoxRSFQDBL2, this.TextBoxRSFQDBL3, this.TextBoxRSFQDBL4, this.TextBoxRSFQDBL5, this.TextBoxRSFQDBL6 };
            TextBox[] tbxGYFQHJ = new TextBox[] { this.TextBoxGYFQHJ1, this.TextBoxGYFQHJ2, this.TextBoxGYFQHJ3, this.TextBoxGYFQHJ4, this.TextBoxGYFQHJ5, this.TextBoxGYFQHJ6 };
            TextBox[] tbxGYFQDBL = new TextBox[] { this.TextBoxGYFQDBL1, this.TextBoxGYFQDBL2, this.TextBoxGYFQDBL3, this.TextBoxGYFQDBL4, this.TextBoxGYFQDBL5, this.TextBoxGYFQDBL6 };
            TextBox[] tbxGYFQCBL = new TextBox[] { this.TextBoxGYFQCBL1, this.TextBoxGYFQCBL2, this.TextBoxGYFQCBL3, this.TextBoxGYFQCBL4, this.TextBoxGYFQCBL5, this.TextBoxGYFQCBL6 };

            int xh;
            while (reader.Read())
            {
                xh = Convert.ToInt32(reader["SRKXH"]) - 1;
                hb[xh].Value = "edit";
                if (xh >= 5)
                {
                    DropDownList6.SelectedValue = reader["CODE"].ToString();
                }
                tbxQCLHJ[xh].Text = reader["DEAL_COUNT"].ToString();
                tbxXZSSQCL[xh].Text = reader["NEW_NUM"].ToString();
                tbxRSFQQCL[xh].Text = reader["coal_cleancnt"].ToString();
                tbxGYFQQCL[xh].Text = reader["tec_cleancnt"].ToString();
                tbxPFLHJ[xh].Text = reader["YEAR_SUMCOUNT"].ToString();
                tbxPFLDBL[xh].Text = reader["REACH_COUNT"].ToString();
                tbxPFLCBL[xh].Text = reader["OVER_COUNT"].ToString();
                tbxRSFQHJ[xh].Text = reader["fire_sumcnt"].ToString();
                tbxRSFQCBL[xh].Text = reader["fire_overcnt"].ToString();
                tbxRSFQDBL[xh].Text = reader["fire_reachcnt"].ToString();
                tbxGYFQHJ[xh].Text = reader["tec_sumcnt"].ToString();
                tbxGYFQDBL[xh].Text = reader["tec_reachcnt"].ToString();
                tbxGYFQCBL[xh].Text = reader["tec_overcnt"].ToString();
            }
            reader.Close();
            sqlcon.Close();
        }
    }

    public string DisplayStr()
    {

        YingYongHanShu yyhs = new YingYongHanShu();

        return yyhs.DisplayStr2("101108");
    }


    protected void ButtonTiJiao_Click(object sender, EventArgs e)
    {
        if (Page.IsValid) //当所有校验控件都正确是才提交
        {

            //**********逻辑判断***********
            //应加入判断输入框 1=2+3，4=5+6，8=10+11，8≥9，12=13+14=15+18，13=16+19，14=17+20，15=16+17，18=19+20
            //污染物（6）不能与（1）到（5）的污染物重复
            //污染物（6）名称为空时，要提示该污染物的数据不会被保存

            LabelTiShi.Text = "正在提交中，请不要关闭或离开...";
            LabelTiShi.Visible = true;

            sqlcon = new SqlConnection(strCon);
            sqlcon.Open();

            ZhuanHuan zh = new ZhuanHuan();//调用转换类

            string sqlstr = "update a01108_1 set "
                + "gasoutput_number=" + Convert.ToString(zh.StrToDouble(TextBoxQZGYFQPFKSL.Text.Trim()) + zh.StrToDouble(TextBoxQZRSFQPFKSL.Text.Trim()))
                + ",GASOUT_NUM=" + Convert.ToString(zh.StrToDouble(TextBoxQZGYFQPFKSL.Text.Trim()))
                + ",GASCOAL_NUM=" + Convert.ToString(zh.StrToDouble(TextBoxQZRSFQPFKSL.Text.Trim()))
                + ",gas_cnt=" + (zh.StrToDouble(TextBoxQZGYFQPFL.Text.Trim()) + zh.StrToDouble(TextBoxQZRSFQPFL.Text.Trim())).ToString("0.0000")
                + ",tec_outcnt=" + Convert.ToString(zh.StrToDouble(TextBoxQZGYFQPFL.Text.Trim()))
                + ",fire_outcnt=" + Convert.ToString(zh.StrToDouble(TextBoxQZRSFQPFL.Text.Trim()))
                + " where qiyeid=" + Session["qiyeid"] + " and  DATA_MONTH='" + Session["ShenBaoNianDu"] + "'";
            SqlCommand sqlcmd = new SqlCommand(sqlstr, sqlcon);
            sqlcmd.ExecuteNonQuery();

            sqlcon.Close();

            TextBoxPFKSL.Text = Convert.ToString(zh.StrToDouble(TextBoxQZGYFQPFKSL.Text.Trim()) + zh.StrToDouble(TextBoxQZRSFQPFKSL.Text.Trim()));
            TextBoxFQPFL.Text = (zh.StrToDouble(TextBoxQZGYFQPFL.Text.Trim()) + zh.StrToDouble(TextBoxQZRSFQPFL.Text.Trim())).ToString("0.0000");

            //************update 污染物********

            //********申报表里污染物（1）二氧化硫 到 （5）挥发性有机溶剂*********
            //
            //污染物代码，按申报表里污染物名称前面的序号排列,记录(1)汞到(5)悬浮物
            // " 02"二氧化硫, " 01"烟尘, " 50"工业粉尘, " 03"氮氧化物, " 60"挥发性有机溶剂

            string[] wrwdm = new string[] { " 02", " 01", " 50", " 03", " 60" };

            HiddenField[] hb = new HiddenField[] { this.HiddenField1, this.HiddenField2, this.HiddenField3, this.HiddenField4, this.HiddenField5, this.HiddenField6 };
            TextBox[] tbxXZSSQCL = new TextBox[] { this.TextBoxXZSSQCL1, this.TextBoxXZSSQCL2, this.TextBoxXZSSQCL3, this.TextBoxXZSSQCL4, this.TextBoxXZSSQCL5, this.TextBoxXZSSQCL6 };
            TextBox[] tbxRSFQQCL = new TextBox[] { this.TextBoxRSFQQCL1, this.TextBoxRSFQQCL2, this.TextBoxRSFQQCL3, this.TextBoxRSFQQCL4, this.TextBoxRSFQQCL5, this.TextBoxRSFQQCL6 };
            TextBox[] tbxGYFQQCL = new TextBox[] { this.TextBoxGYFQQCL1, this.TextBoxGYFQQCL2, this.TextBoxGYFQQCL3, this.TextBoxGYFQQCL4, this.TextBoxGYFQQCL5, this.TextBoxGYFQQCL6 };
            TextBox[] tbxRSFQDBL = new TextBox[] { this.TextBoxRSFQDBL1, this.TextBoxRSFQDBL2, this.TextBoxRSFQDBL3, this.TextBoxRSFQDBL4, this.TextBoxRSFQDBL5, this.TextBoxRSFQDBL6 };
            TextBox[] tbxRSFQCBL = new TextBox[] { this.TextBoxRSFQCBL1, this.TextBoxRSFQCBL2, this.TextBoxRSFQCBL3, this.TextBoxRSFQCBL4, this.TextBoxRSFQCBL5, this.TextBoxRSFQCBL6 };
            TextBox[] tbxGYFQDBL = new TextBox[] { this.TextBoxGYFQDBL1, this.TextBoxGYFQDBL2, this.TextBoxGYFQDBL3, this.TextBoxGYFQDBL4, this.TextBoxGYFQDBL5, this.TextBoxGYFQDBL6 };
            TextBox[] tbxGYFQCBL = new TextBox[] { this.TextBoxGYFQCBL1, this.TextBoxGYFQCBL2, this.TextBoxGYFQCBL3, this.TextBoxGYFQCBL4, this.TextBoxGYFQCBL5, this.TextBoxGYFQCBL6 };
            TextBox[] tbxQCLHJ = new TextBox[] { this.TextBoxQCLHJ1, this.TextBoxQCLHJ2, this.TextBoxQCLHJ3, this.TextBoxQCLHJ4, this.TextBoxQCLHJ5, this.TextBoxQCLHJ6 };
            TextBox[] tbxPFLHJ = new TextBox[] { this.TextBoxPFLHJ1, this.TextBoxPFLHJ2, this.TextBoxPFLHJ3, this.TextBoxPFLHJ4, this.TextBoxPFLHJ5, this.TextBoxPFLHJ6 };
            TextBox[] tbxPFLDBL = new TextBox[] { this.TextBoxPFLDBL1, this.TextBoxPFLDBL2, this.TextBoxPFLDBL3, this.TextBoxPFLDBL4, this.TextBoxPFLDBL5, this.TextBoxPFLDBL6 };
            TextBox[] tbxPFLCBL = new TextBox[] { this.TextBoxPFLCBL1, this.TextBoxPFLCBL2, this.TextBoxPFLCBL3, this.TextBoxPFLCBL4, this.TextBoxPFLCBL5, this.TextBoxPFLCBL6 };
            TextBox[] tbxRSFQHJ = new TextBox[] { this.TextBoxRSFQHJ1, this.TextBoxRSFQHJ2, this.TextBoxRSFQHJ3, this.TextBoxRSFQHJ4, this.TextBoxRSFQHJ5, this.TextBoxRSFQHJ6 };
            TextBox[] tbxGYFQHJ = new TextBox[] { this.TextBoxGYFQHJ1, this.TextBoxGYFQHJ2, this.TextBoxGYFQHJ3, this.TextBoxGYFQHJ4, this.TextBoxGYFQHJ5, this.TextBoxGYFQHJ6 };


            for (int i = 0; i <= 4; i++)
            {
                if (hb[i].Value == "edit")
                {
                    sqlstr = "update a01108_2 set "
                    + "DEAL_COUNT=" + Convert.ToString(zh.StrToDouble(tbxRSFQQCL[i].Text.Trim()) + zh.StrToDouble(tbxGYFQQCL[i].Text.Trim()))
                    + ",NEW_NUM=" + Convert.ToString(zh.StrToDouble(tbxXZSSQCL[i].Text.Trim()))
                    + ",coal_cleancnt=" + Convert.ToString(zh.StrToDouble(tbxRSFQQCL[i].Text.Trim()))
                    + ",tec_cleancnt=" + Convert.ToString(zh.StrToDouble(tbxGYFQQCL[i].Text.Trim()))
                    + ",YEAR_SUMCOUNT=" + Convert.ToString(zh.StrToDouble(tbxRSFQDBL[i].Text.Trim()) + zh.StrToDouble(tbxRSFQCBL[i].Text.Trim()) + zh.StrToDouble(tbxGYFQDBL[i].Text.Trim()) + zh.StrToDouble(tbxGYFQCBL[i].Text.Trim()))
                    + ",REACH_COUNT=" + Convert.ToString(zh.StrToDouble(tbxRSFQDBL[i].Text.Trim()) + zh.StrToDouble(tbxGYFQDBL[i].Text.Trim()))
                    + ",OVER_COUNT=" + Convert.ToString(zh.StrToDouble(tbxRSFQCBL[i].Text.Trim()) + zh.StrToDouble(tbxGYFQCBL[i].Text.Trim()))
                    + ",fire_sumcnt=" + Convert.ToString(zh.StrToDouble(tbxRSFQDBL[i].Text.Trim()) + zh.StrToDouble(tbxRSFQCBL[i].Text.Trim()))
                    + ",fire_reachcnt=" + Convert.ToString(zh.StrToDouble(tbxRSFQDBL[i].Text.Trim()))
                    + ",fire_overcnt=" + Convert.ToString(zh.StrToDouble(tbxRSFQCBL[i].Text.Trim()))
                    + ",tec_sumcnt=" + Convert.ToString(zh.StrToDouble(tbxGYFQDBL[i].Text.Trim()) + zh.StrToDouble(tbxGYFQCBL[i].Text.Trim()))
                    + ",tec_reachcnt=" + Convert.ToString(zh.StrToDouble(tbxGYFQDBL[i].Text.Trim()))
                    + ",tec_overcnt=" + Convert.ToString(zh.StrToDouble(tbxGYFQCBL[i].Text.Trim()))
                    + " where SRKXH= " + Convert.ToString(i + 1)
                    + " and qiyeid=" + Session["qiyeid"] + " and  DATA_MONTH='" + Session["ShenBaoNianDu"] + "'";

                    sqlcon.Close();
                    sqlcmd.CommandText = sqlstr;
                    sqlcon.Open();
                    sqlcmd.ExecuteNonQuery();

                    //解决提交页面刷新后变动回旧值得问题
                    tbxQCLHJ[i].Text = Convert.ToString(zh.StrToDouble(tbxRSFQQCL[i].Text.Trim()) + zh.StrToDouble(tbxGYFQQCL[i].Text.Trim()));
                    tbxPFLHJ[i].Text = Convert.ToString(zh.StrToDouble(tbxRSFQDBL[i].Text.Trim()) + zh.StrToDouble(tbxRSFQCBL[i].Text.Trim()) + zh.StrToDouble(tbxGYFQDBL[i].Text.Trim()) + zh.StrToDouble(tbxGYFQCBL[i].Text.Trim()));
                    tbxPFLDBL[i].Text = Convert.ToString(zh.StrToDouble(tbxRSFQDBL[i].Text.Trim()) + zh.StrToDouble(tbxGYFQDBL[i].Text.Trim()));
                    tbxPFLCBL[i].Text = Convert.ToString(zh.StrToDouble(tbxRSFQCBL[i].Text.Trim()) + zh.StrToDouble(tbxGYFQCBL[i].Text.Trim()));
                    tbxRSFQHJ[i].Text = Convert.ToString(zh.StrToDouble(tbxRSFQDBL[i].Text.Trim()) + zh.StrToDouble(tbxRSFQCBL[i].Text.Trim()));
                    tbxGYFQHJ[i].Text = Convert.ToString(zh.StrToDouble(tbxGYFQDBL[i].Text.Trim()) + zh.StrToDouble(tbxGYFQCBL[i].Text.Trim()));
                }
                else//新增
                {
                    if ((tbxXZSSQCL[i].Text.Trim() != "") || (tbxRSFQQCL[i].Text.Trim() != "") || (tbxGYFQQCL[i].Text.Trim() != "") || (tbxRSFQDBL[i].Text.Trim() != "") || (tbxRSFQCBL[i].Text.Trim() != "") || (tbxGYFQDBL[i].Text.Trim() != "") || (tbxGYFQCBL[i].Text.Trim() != ""))
                    {
                        sqlstr = "insert into a01108_2(DEAL_COUNT,NEW_NUM,coal_cleancnt,tec_cleancnt,YEAR_SUMCOUNT,REACH_COUNT,OVER_COUNT,fire_sumcnt,fire_reachcnt,fire_overcnt,tec_sumcnt,tec_reachcnt,tec_overcnt,SRKXH,CODE,DATA_MONTH,qiyeid) values("
                         + Convert.ToString(zh.StrToDouble(tbxRSFQQCL[i].Text.Trim()) + zh.StrToDouble(tbxGYFQQCL[i].Text.Trim()))
                     + "," + Convert.ToString(zh.StrToDouble(tbxXZSSQCL[i].Text.Trim()))
                     + "," + Convert.ToString(zh.StrToDouble(tbxRSFQQCL[i].Text.Trim()))
                     + "," + Convert.ToString(zh.StrToDouble(tbxGYFQQCL[i].Text.Trim()))
                     + "," + Convert.ToString(zh.StrToDouble(tbxRSFQDBL[i].Text.Trim()) + zh.StrToDouble(tbxRSFQCBL[i].Text.Trim()) + zh.StrToDouble(tbxGYFQDBL[i].Text.Trim()) + zh.StrToDouble(tbxGYFQCBL[i].Text.Trim()))
                     + "," + Convert.ToString(zh.StrToDouble(tbxRSFQDBL[i].Text.Trim()) + zh.StrToDouble(tbxGYFQDBL[i].Text.Trim()))
                     + "," + Convert.ToString(zh.StrToDouble(tbxRSFQCBL[i].Text.Trim()) + zh.StrToDouble(tbxGYFQCBL[i].Text.Trim()))
                     + "," + Convert.ToString(zh.StrToDouble(tbxRSFQDBL[i].Text.Trim()) + zh.StrToDouble(tbxRSFQCBL[i].Text.Trim()))
                     + "," + Convert.ToString(zh.StrToDouble(tbxRSFQDBL[i].Text.Trim()))
                     + "," + Convert.ToString(zh.StrToDouble(tbxRSFQCBL[i].Text.Trim()))
                     + "," + Convert.ToString(zh.StrToDouble(tbxGYFQDBL[i].Text.Trim()) + zh.StrToDouble(tbxGYFQCBL[i].Text.Trim()))
                     + "," + Convert.ToString(zh.StrToDouble(tbxGYFQDBL[i].Text.Trim()))
                     + "," + Convert.ToString(zh.StrToDouble(tbxGYFQCBL[i].Text.Trim()))
                     + "," + Convert.ToString(i + 1) + ",'" + wrwdm[i] + "','" + Session["ShenBaoNianDu"] + " '," + Session["qiyeid"] + ")";

                        sqlcon.Close();
                        sqlcmd.CommandText = sqlstr;
                        sqlcon.Open();
                        sqlcmd.ExecuteNonQuery();

                        hb[i].Value = "edit";

                        //解决提交页面刷新后变动回旧值得问题
                        tbxQCLHJ[i].Text = Convert.ToString(zh.StrToDouble(tbxRSFQQCL[i].Text.Trim()) + zh.StrToDouble(tbxGYFQQCL[i].Text.Trim()));
                        tbxPFLHJ[i].Text = Convert.ToString(zh.StrToDouble(tbxRSFQDBL[i].Text.Trim()) + zh.StrToDouble(tbxRSFQCBL[i].Text.Trim()) + zh.StrToDouble(tbxGYFQDBL[i].Text.Trim()) + zh.StrToDouble(tbxGYFQCBL[i].Text.Trim()));
                        tbxPFLDBL[i].Text = Convert.ToString(zh.StrToDouble(tbxRSFQDBL[i].Text.Trim()) + zh.StrToDouble(tbxGYFQDBL[i].Text.Trim()));
                        tbxPFLCBL[i].Text = Convert.ToString(zh.StrToDouble(tbxRSFQCBL[i].Text.Trim()) + zh.StrToDouble(tbxGYFQCBL[i].Text.Trim()));
                        tbxRSFQHJ[i].Text = Convert.ToString(zh.StrToDouble(tbxRSFQDBL[i].Text.Trim()) + zh.StrToDouble(tbxRSFQCBL[i].Text.Trim()));
                        tbxGYFQHJ[i].Text = Convert.ToString(zh.StrToDouble(tbxGYFQDBL[i].Text.Trim()) + zh.StrToDouble(tbxGYFQCBL[i].Text.Trim()));
                    }
                }
            }

            //*******污染物(6) *******用户自己选择污染物呢名称的

            int j = 5;
            if (!(DropDownList6.Text.Trim() == ""))
            {

                if (hb[j].Value == "edit")
                {
                    sqlstr = "update a01108_2 set "
                       + "DEAL_COUNT=" + Convert.ToString(zh.StrToDouble(tbxRSFQQCL[j].Text.Trim()) + zh.StrToDouble(tbxGYFQQCL[j].Text.Trim()))
                       + ",NEW_NUM=" + Convert.ToString(zh.StrToDouble(tbxXZSSQCL[j].Text.Trim()))
                       + ",coal_cleancnt=" + Convert.ToString(zh.StrToDouble(tbxRSFQQCL[j].Text.Trim()))
                       + ",tec_cleancnt=" + Convert.ToString(zh.StrToDouble(tbxGYFQQCL[j].Text.Trim()))
                       + ",YEAR_SUMCOUNT=" + Convert.ToString(zh.StrToDouble(tbxRSFQDBL[j].Text.Trim()) + zh.StrToDouble(tbxRSFQCBL[j].Text.Trim()) + zh.StrToDouble(tbxGYFQDBL[j].Text.Trim()) + zh.StrToDouble(tbxGYFQCBL[j].Text.Trim()))
                       + ",REACH_COUNT=" + Convert.ToString(zh.StrToDouble(tbxRSFQDBL[j].Text.Trim()) + zh.StrToDouble(tbxGYFQDBL[j].Text.Trim()))
                       + ",OVER_COUNT=" + Convert.ToString(zh.StrToDouble(tbxRSFQCBL[j].Text.Trim()) + zh.StrToDouble(tbxGYFQCBL[j].Text.Trim()))
                       + ",fire_sumcnt=" + Convert.ToString(zh.StrToDouble(tbxRSFQDBL[j].Text.Trim()) + zh.StrToDouble(tbxRSFQCBL[j].Text.Trim()))
                       + ",fire_reachcnt=" + Convert.ToString(zh.StrToDouble(tbxRSFQDBL[j].Text.Trim()))
                       + ",fire_overcnt=" + Convert.ToString(zh.StrToDouble(tbxRSFQCBL[j].Text.Trim()))
                       + ",tec_sumcnt=" + Convert.ToString(zh.StrToDouble(tbxGYFQDBL[j].Text.Trim()) + zh.StrToDouble(tbxGYFQCBL[j].Text.Trim()))
                       + ",tec_reachcnt=" + Convert.ToString(zh.StrToDouble(tbxGYFQDBL[j].Text.Trim()))
                       + ",tec_overcnt=" + Convert.ToString(zh.StrToDouble(tbxGYFQCBL[j].Text.Trim()))
                       + ",CODE='" + DropDownList6.SelectedValue + "'"
                       + " where SRKXH=  " + Convert.ToString(j + 1)
                       + " and qiyeid=" + Session["qiyeid"] + " and  DATA_MONTH='" + Session["ShenBaoNianDu"] + "'";

                    sqlcon.Close();
                    sqlcmd.CommandText = sqlstr;
                    sqlcon.Open();
                    sqlcmd.ExecuteNonQuery();

                    //解决提交页面刷新后变动回旧值得问题
                    tbxQCLHJ[j].Text = Convert.ToString(zh.StrToDouble(tbxRSFQQCL[j].Text.Trim()) + zh.StrToDouble(tbxGYFQQCL[j].Text.Trim()));
                    tbxPFLHJ[j].Text = Convert.ToString(zh.StrToDouble(tbxRSFQDBL[j].Text.Trim()) + zh.StrToDouble(tbxRSFQCBL[j].Text.Trim()) + zh.StrToDouble(tbxGYFQDBL[j].Text.Trim()) + zh.StrToDouble(tbxGYFQCBL[j].Text.Trim()));
                    tbxPFLDBL[j].Text = Convert.ToString(zh.StrToDouble(tbxRSFQDBL[j].Text.Trim()) + zh.StrToDouble(tbxGYFQDBL[j].Text.Trim()));
                    tbxPFLCBL[j].Text = Convert.ToString(zh.StrToDouble(tbxRSFQCBL[j].Text.Trim()) + zh.StrToDouble(tbxGYFQCBL[j].Text.Trim()));
                    tbxRSFQHJ[j].Text = Convert.ToString(zh.StrToDouble(tbxRSFQDBL[j].Text.Trim()) + zh.StrToDouble(tbxRSFQCBL[j].Text.Trim()));
                    tbxGYFQHJ[j].Text = Convert.ToString(zh.StrToDouble(tbxGYFQDBL[j].Text.Trim()) + zh.StrToDouble(tbxGYFQCBL[j].Text.Trim()));
                }
                else//新增
                {
                    if ((tbxXZSSQCL[j].Text.Trim() != "") || (tbxRSFQQCL[j].Text.Trim() != "") || (tbxGYFQQCL[j].Text.Trim() != "") || (tbxRSFQDBL[j].Text.Trim() != "") || (tbxRSFQCBL[j].Text.Trim() != "") || (tbxGYFQDBL[j].Text.Trim() != "") || (tbxGYFQCBL[j].Text.Trim() != ""))
                    {
                        sqlstr = "insert into a01108_2(DEAL_COUNT,NEW_NUM,coal_cleancnt,tec_cleancnt,YEAR_SUMCOUNT,REACH_COUNT,OVER_COUNT,fire_sumcnt,fire_reachcnt,fire_overcnt,tec_sumcnt,tec_reachcnt,tec_overcnt,SRKXH,CODE,DATA_MONTH,qiyeid) values("
                         + Convert.ToString(zh.StrToDouble(tbxRSFQQCL[j].Text.Trim()) + zh.StrToDouble(tbxGYFQQCL[j].Text.Trim()))
                     + "," + Convert.ToString(zh.StrToDouble(tbxXZSSQCL[j].Text.Trim()))
                     + "," + Convert.ToString(zh.StrToDouble(tbxRSFQQCL[j].Text.Trim()))
                     + "," + Convert.ToString(zh.StrToDouble(tbxGYFQQCL[j].Text.Trim()))
                     + "," + Convert.ToString(zh.StrToDouble(tbxRSFQDBL[j].Text.Trim()) + zh.StrToDouble(tbxRSFQCBL[j].Text.Trim()) + zh.StrToDouble(tbxGYFQDBL[j].Text.Trim()) + zh.StrToDouble(tbxGYFQCBL[j].Text.Trim()))
                     + "," + Convert.ToString(zh.StrToDouble(tbxRSFQDBL[j].Text.Trim()) + zh.StrToDouble(tbxGYFQDBL[j].Text.Trim()))
                     + "," + Convert.ToString(zh.StrToDouble(tbxRSFQCBL[j].Text.Trim()) + zh.StrToDouble(tbxGYFQCBL[j].Text.Trim()))
                     + "," + Convert.ToString(zh.StrToDouble(tbxRSFQDBL[j].Text.Trim()) + zh.StrToDouble(tbxRSFQCBL[j].Text.Trim()))
                     + "," + Convert.ToString(zh.StrToDouble(tbxRSFQDBL[j].Text.Trim()))
                     + "," + Convert.ToString(zh.StrToDouble(tbxRSFQCBL[j].Text.Trim()))
                     + "," + Convert.ToString(zh.StrToDouble(tbxGYFQDBL[j].Text.Trim()) + zh.StrToDouble(tbxGYFQCBL[j].Text.Trim()))
                     + "," + Convert.ToString(zh.StrToDouble(tbxGYFQDBL[j].Text.Trim()))
                     + "," + Convert.ToString(zh.StrToDouble(tbxGYFQCBL[j].Text.Trim()))
                     + "," + Convert.ToString(j + 1) + ",'" + DropDownList6.SelectedValue + "','" + Session["ShenBaoNianDu"] + " '," + Session["qiyeid"] + ")";

                        sqlcon.Close();
                        sqlcmd.CommandText = sqlstr;
                        sqlcon.Open();
                        sqlcmd.ExecuteNonQuery();

                        hb[j].Value = "edit";

                        //解决提交页面刷新后变动回旧值得问题
                        tbxQCLHJ[j].Text = Convert.ToString(zh.StrToDouble(tbxRSFQQCL[j].Text.Trim()) + zh.StrToDouble(tbxGYFQQCL[j].Text.Trim()));
                        tbxPFLHJ[j].Text = Convert.ToString(zh.StrToDouble(tbxRSFQDBL[j].Text.Trim()) + zh.StrToDouble(tbxRSFQCBL[j].Text.Trim()) + zh.StrToDouble(tbxGYFQDBL[j].Text.Trim()) + zh.StrToDouble(tbxGYFQCBL[j].Text.Trim()));
                        tbxPFLDBL[j].Text = Convert.ToString(zh.StrToDouble(tbxRSFQDBL[j].Text.Trim()) + zh.StrToDouble(tbxGYFQDBL[j].Text.Trim()));
                        tbxPFLCBL[j].Text = Convert.ToString(zh.StrToDouble(tbxRSFQCBL[j].Text.Trim()) + zh.StrToDouble(tbxGYFQCBL[j].Text.Trim()));
                        tbxRSFQHJ[j].Text = Convert.ToString(zh.StrToDouble(tbxRSFQDBL[j].Text.Trim()) + zh.StrToDouble(tbxRSFQCBL[j].Text.Trim()));
                        tbxGYFQHJ[j].Text = Convert.ToString(zh.StrToDouble(tbxGYFQDBL[j].Text.Trim()) + zh.StrToDouble(tbxGYFQCBL[j].Text.Trim()));
                    }
                }
            }

            //TextBoxWSPFL.Text = Convert.ToString(zh.StrToDouble(TextBoxCBPFL.Text.Trim()) + zh.StrToDouble(TextBoxDBPFL.Text.Trim()));//解决提交页面刷新后变动回旧值得问题

            sqlcon.Close();

            LabelTiShi.Visible = false;
            MessageBox("tishi", "你所填写申报内容正确，已成功提交!");
        }
    }


    //// <summary> 
    /// 弹出提示信息框 
    /// </summary> 
    /// <param name="strKey">函数key值</param> 
    /// <param name="strInfo">提示信息</param> 
    public void MessageBox(string strKey, string strInfo)
    {
        if (!ClientScript.IsClientScriptBlockRegistered(strKey))
        {
            string strjs = "alert('" + strInfo + "');";
            ClientScript.RegisterClientScriptBlock(this.GetType(), strKey, strjs, true);
        }
    } 

}